<template>
  <!-- 执行完 -->
  <div>
    <div v-if="!(CompleteExecute.actualCost==null && CompleteExecute.executeDate==null)">
        <el-descriptions title="" border direction="vertical">
            <el-descriptions-item label="实际成本" v-if="CompleteExecute.actualCost!==null">{{CompleteExecute.actualCost}}</el-descriptions-item>
            <el-descriptions-item label="执行完时间" v-if="CompleteExecute.executeDate!==null">{{CompleteExecute.executeDate}}</el-descriptions-item>
        </el-descriptions>
    </div>
    <div style="margin: 0 20px;">
        <div style="display: flex;align-items: center;margin-bottom: 20px;">
            <div style="font-size: 14px;">
                文件类型：
            </div>
            <el-select v-model="SysLabel" multiple @change="handselectchange" placeholder="请选择">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
        </div>
        <el-table
        :data="dataList"
        style="width: 100%"
        border>
         <el-table-column
          prop="id"
          label="编号">
        </el-table-column>
        <el-table-column
          prop="fileName"
          label="文件名称"
         >
        </el-table-column>
        <el-table-column
          prop="fileTypeName"
          label="文件类型"
         >
        </el-table-column>
        <el-table-column
        prop="remark"
        label="备注">
      </el-table-column>
      <el-table-column
      prop="createPerson"
      label="创建人">
    </el-table-column>
    <el-table-column
    prop="createTime"
    label="创建时间">
    <template slot-scope="scope">
        <div>
            {{ formatterTime(scope.row.createTime) }}
        </div>
        </template>
  </el-table-column>
        <el-table-column
        label="操作">
        <template slot-scope="scope">
        <div>
          <FileDownloader
          :fileUrl="scope.row.filePath || ''"
          :fileName="scope.row.fileName || ''"
        />
        </div>
        </template>
      </el-table-column>
      </el-table>
      <div class="global-page">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="pageSizes"
            :page-size="pageSize"
            :current-page="pageNum"
            background
            layout="sizes, total, prev, pager, next"
            :total="total"
          >
          </el-pagination>
        </div>
    </div>

 
  </div>
</template>

<script>
import APIdetail from "@/api/apidetail";
import APIProjectFile from "@/api/apiProjectFile";
import FileDownloader from "@/components/utils/FileDownloader";
export default {
    props: {
    operationList: Array,
    currentStageid: Number,
  },
  components: {
    FileDownloader,
  },
  data() {
    return { dataList: [{
            date: '2016-05-02',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1518 弄'
          }, {
            date: '2016-05-04',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1517 弄'
          }, {
            date: '2016-05-01',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1519 弄'
          }, {
            date: '2016-05-03',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1516 弄'
          }],
          pageNum:1,
          pageSize:15,
          total: 0,
      pageSizes: [10, , 15, 20, 50],
      projectId:null,
      options: [{
          value: 5090,
          label: '资质'
        }, {
          value: 5091,
          label: '结案反馈pdf'
        }, {
          value: 5092,
          label: '反馈压缩包'
        }, {
          value: 5093,
          label: '其他'
        }],
        SysLabel:'',
        fileTypelist:[5090,5091,5092,5093],
        CompleteExecute:{}

        };
  },

  methods:{
        // 分页pageSize改变
        handleSizeChange(e) {
      this.pageSize = e;
      
    },
    // 分页pageNum改变
    handleCurrentChange(e) {
      this.pageNum = e;
     
    },

    getProjectFileList(){
        let params = {
            fileType:this.fileTypelist.join(','),
            pageNum:this.pageNum,
            pageSize:this.pageSize,
            projectId:this.projectId,
            stageId:this.currentStageid
        }
        APIProjectFile.getProjectFileList(params).then(res=>{
            if(res.key==1000){
                this.dataList = res.result.list;
            }
        })
    },
    getCompleteExecute(){
let params = {
    projectId:this.projectId
}
APIdetail.getCompleteExecute(params).then(res=>{
   if(res.key == 1000){
    this.CompleteExecute = res.result.data;
   }
})
    },
    handselectchange(val){
        console.log(val)
        this.fileTypelist = val;
        this.getProjectFileList();
    },
    formatterTime(time) {
      return this.$moment(time).format("YYYY-MM-DD HH:mm:ss");
    },

  },
  created(){
    let projectId = this.$ls.get("projectId");
    if (projectId) {
      this.projectId = projectId;
      this.getProjectFileList();
      this.getCompleteExecute()
    }
  }
};
</script>
